package shuishijie.suishijie.model;

import android.util.Log;

import shuishijie.suishijie.BuildConfig;


/**
 * Created by mindx on 2016/10/13.
 */

public class EnvConfig {
    private static final String TAG = EnvConfig.class.getSimpleName();

    static {
       // setEnv(ENV_TYPE.valueOf(BuildConfig.envType));
    }

    public static final String URL_CELEBRITY = "http://mall.fcp9999.com/dist/index.html#/load/appcelebrity-introduction";
    public static final String URL_LICENSE = "http://mall.fcp9999.com/problem/userAgreement.htm";
    public static final String URL_HELP = "http://mall.fcp9999.com/problem/problemIndex.htm";
    public static String WEB_URL = "http://mall.fcp9999.com";


    private static String discription;
    private static String h5env;
    private static String SERVER_URL;
    private static String SHOP_URL;
    private static String MQTT_BROKER;
    //    private static String DEVICE = "POT";
    private static String DEVICE = "WEIGHT";

    private static ENV_TYPE currentEnv;

    public static void setEnv(ENV_TYPE envType) {
        EnvConfig.currentEnv = envType;
        Log.d(TAG, "env type: " + envType);
        switch (envType) {
            case ENV_DEVELOP:
                discription = "测试环境";
                h5env = "uat";
                WEB_URL = "http://mall.fcp9999.com";
                SERVER_URL = "http://mall.api.fcp9999.com";
                break;
            case ENV_PRODUCT:
                discription = "生产环境";
                h5env = "prod";
                WEB_URL = "http://mall.fcp9999.com";
                SERVER_URL = "http://mall.api.fcp9999.com";
            default:
                break;
        }
    }

    public static boolean isPot() {
        return DEVICE.equalsIgnoreCase("POT");
    }

    public static String changeEnv() {
        if (BuildConfig.DEBUG) {
            if (currentEnv == ENV_TYPE.ENV_PRODUCT) {
                currentEnv = ENV_TYPE.ENV_DEVELOP;
            } else {
                currentEnv = ENV_TYPE.ENV_PRODUCT;
            }
            setEnv(currentEnv);
        }
        return currentEnv.toString();
    }

    public static ENV_TYPE getCurrentEnv() {
        return currentEnv;
    }

    public static String getDiscription() {
        return discription;
    }

    public static String getH5env() {
        return h5env;
    }

    public static String getMqttBroker() {
        return MQTT_BROKER;
    }

    public static String getServerUrl() {
        return SERVER_URL;
    }

    public static String getIPReportServerUrl() {
        /**
         * 	主　题：	国美生产服务器IP获取   [举报垃圾邮件] [新窗口打开]
         * 	时　间：	2016-10-25 16:19 (星期二)
         * 	发件人：	"思界科技" <xiemc@mindx.cn>
         *
         * 	针对业务需求需要获取客户端IP，调用/report 接口的时候需要指定8995端口，
         * 	只有调用此端口，服务器端才能获取到客户端IP。此次变更针对国美测试与生产服务器，请知悉
         * 	2016-11-11 又改443
         */
        String url = EnvConfig.getServerUrl();
        int index = url.lastIndexOf(":");
        if (index > 0) {
            url = url.substring(0, index) + ":443";
        }
        return url;
    }

    public static String getShopUrl() {
        return SHOP_URL;
    }

    public static String getWeb() {
        return WEB_URL;
    }


    public enum ENV_TYPE {
        ENV_DEVELOP,
        ENV_PRODUCT,
    }
}
